import uiManager from "./uiManager";

const {ccclass, property} = cc._decorator;

@ccclass
export default class ninja extends cc.Component {

    private uiManager:uiManager = null;
    init(uiManager:uiManager){
        this.uiManager = uiManager

    }

    // 忍者与柱子碰撞时
    onCollisionEnter(other,self){
        this.uiManager.ninjaTween.stop()
        this.node.y = other.node.y + this.node.height/2 + other.node.height/2 + 10
        if(this.node.x > other.node.x + other.node.width/2){
            this.node.x = other.node.x + other.node.width/2
        }
        if(this.node.x < other.node.x - other.node.width/2){
            this.node.x = other.node.x - other.node.width/2
        }
        this.node.angle = 0
         cc.resources.load('64015',cc.SpriteFrame,(err,res)=>{
            this.node.getComponent(cc.Sprite).spriteFrame = res
        })
        this.uiManager.isEndAction = true
        this.uiManager.addScore()
    }
}
